package com.net.xpay.core.dao;

import com.net.xpay.common.enums.invoice.OpenInvoiceStatus;
import com.net.xpay.core.domain.ChargeRecord;
import com.net.xpay.core.model.ChargeRecordSearchModel;
import com.net.common.annotation.DataShard;
import com.net.common.dao.Page;
import com.net.common.dao.PagedMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@DataShard("")
@Repository
public interface ChargeRecordMapper extends PagedMapper<Long, ChargeRecord> {
    List<ChargeRecord> search(@Param("searchModel") ChargeRecordSearchModel searchModel, @Param("page") Page page);

    long searchCount(@Param("searchModel") ChargeRecordSearchModel searchModel);

    /**
     * @param positive 1正  0负
     */
    long statChargeAmount(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime, @Param("positive") Integer positive);

    List<ChargeRecord> list(@Param("searchModel")ChargeRecordSearchModel searchModel);

    ChargeRecord findLastPaid(@Param("userId")Long userId);

    Long statWaitInvoicingAmount(@Param("userId")Long userId,@Param("startTime") LocalDateTime startTime);

    int updateOpenInvoiceStatusByIds(@Param("ids")List<Long> ids, @Param("status") OpenInvoiceStatus status);

    List<ChargeRecord> listByIds(@Param("ids")List<Long> ids);

    //统计通过支付宝当面付扫码充值的服务费
    long statAmountByAlipayAppQrcode(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long statUserAmountByAlipayAppQrcode(@Param("userId") Long userId, @Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long sumServiceChargeFeeByDay(@Param("partnerId")Long partnerId,@Param("minEndTime") LocalDateTime minEndTime,@Param("maxEndTime") LocalDateTime maxEndTime);

    long sumUserServiceChargeFeeByDay(@Param("userId")Long userId,@Param("minEndTime") LocalDateTime minEndTime,@Param("maxEndTime") LocalDateTime maxEndTime);

    long sumCompanyServiceChargeFeeByDay(@Param("minEndTime") LocalDateTime minEndTime,@Param("maxEndTime") LocalDateTime maxEndTime);
}
